/**
 * @param: fileType - 文件类型
 * @param: fileName - 文件名称
 * @param: data  - 数据流文件
 **/
export function download(fileType, bucketName, data) {
  let downType = "";
  let downName = "";
  if (fileType == "image") {
    downType = "image/png";
    downName = fileName + ".png";
  } else if (fileType == "word") {
    downType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
    downName = fileName + ".docx";
  } else if (fileType == "video") {
    downType = "video/mpeg4";
    downName = fileName + ".mp4";
  } else if (fileType == "radio") {
    downType = "audio/mpeg";
    downName = fileName + ".mp3";
  } else if (fileType == "pdf") {
    downType = "application/pdf";
    downName = fileName + ".pdf";
  }
  let blob = new Blob([data], { type: downType });
  let downloadElement = document.createElement("a");
  let href = window.URL.createObjectURL(blob);
  downloadElement.href = href;
  document.body.appendChild(downloadElement);
  //downloadElement.setAttribute("download", downName);//设置下载名称
  downloadElement.download = downName; //设置下载文件名称
  downloadElement.click();
  document.body.removeChild(downloadElement); //移除元素；防止连续点击创建多个a标签
  window.URL.revokeObjectURL(href);
}